from django.http import HttpRequest

from ali_oss import forms
from ali_oss.application.service import AliOssService
from common.http_utils import SuccessResponse


def upload_file(request: HttpRequest):
    file = request.FILES.get("file")
    save_dir = request.GET.get("save_dir")
    service = AliOssService()
    url = service.upload(file, save_dir)
    return SuccessResponse({"url": url})
